package com.flnet.spsys.controller;

import com.flnet.spsys.entity.TestParam;
import com.flnet.spsys.entity.TestParamChild;
import com.flnet.spsys.entity.VO.UserLoginVO;
import com.flnet.spsys.utils.ResultJson;
import io.swagger.annotations.Api;
import org.joda.time.DateTime;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Api(tags = "参数测试")
@RestController
@RequestMapping("/test")
@CrossOrigin
public class TestParamController {

    @ResponseBody
    @GetMapping(value = "/param")
    @CrossOrigin
    public Object getParam() {
        TestParam testParam = new TestParam();
        testParam.setId(100);
        testParam.setName("parent");
        testParam.setDesc("desc");
        List<TestParamChild> children = new ArrayList<>();
        children.add(new TestParamChild(1,"1",new Date()));
        children.add(new TestParamChild(2,"2",new Date()));
        children.add(new TestParamChild(3,"3",new Date()));
        testParam.setChildren(children);
        return ResultJson.success(testParam);
    }

    @ResponseBody
    @PostMapping(value = "/param")
    @CrossOrigin
    public Object postParam(@RequestBody TestParam testParam) {
        return ResultJson.success(testParam);
    }
}
